<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<div id="dialog-message_class">
	<div style="height:400px;overflow:auto;">
		<ul id="TeacherTree" class="ztree"></ul>
	</div>
	<div>
		<hr>
		当前教学计划适用范围：<div id="learnPlant_andSchooltextButton" class="btn btn-info"></div>
	</div>
</div>
<script type="text/javascript">
(function(){
	
	var arr = new Array();
	var callbackTree ={
			click:function(event, treeId, treeNode){
				var arr1 = new Array();
				var b =false;
				//两个数组是用来，如果有就删除，没有就增加的
				for(var i=0;i<arr.length;i++){
					if(arr[i].table_id == treeNode.table_id){
						b=true;
					}else{
						arr1.push(arr[i]);
					}
				}
				if(b==true){
					arr =arr1;
				}else{
					 var node = new Object();
					 node.table_id = treeNode.table_id;
					 node.text = treeNode.pName;
					 arr.push(node);
				}   
				//显示出来
				
				var vt ="";
				
				for(var i=0;i<arr.length;i++){
					if(i==arr.length-1){
						vt+='<button class="btn btn-xs btn-inverse" style="margin-top:4px;" name="classbuton" table_id="'+arr[i].table_id+'">'+arr[i].text+'<i class="icon-remove"></i></button>'; 
					}else{
						vt+='<button class="btn btn-xs btn-inverse" style="margin-top:4px;" name="classbuton" table_id="'+arr[i].table_id+'">'+arr[i].text+'<i class="icon-remove"></i></button>&nbsp;';
					}
				}
				$("#learnPlant_andSchooltextButton").html(vt);
				$("#learnPlant_addClass_show").html(vt); 
				$("button[name=classbuton]").click(function(){
					$(this).remove();
				});
			}
	}
	var treeObj =window.myjs.loadTree("TeacherTree",callbackTree);
	function addLearnPlantClass(contrl){
			$("#learnPlant_addClass").data("arr",arr);
			$(contrl).dialog("destroy" ); 
			$("#learnPlantAdd_ClassWindow").html(""); 
	};
	window.dialog_message_class={};
	window.dialog_message_class.addLearnPlantClass =addLearnPlantClass;
})();
</script> 